import { Injectable } from '@angular/core';

@Injectable({
  providedIn: 'root'
})
export class MessageService {

  messages : string[] = [];

  constructor() {

  }

  //增加消息
  addMessage(message : string):void{
      if(message.length > 0) {
        this.messages.push(message);
      }
  }

  //移除消息
  removeLastMessage() : void{
    if(this.messages.length  > 0){
      this.messages.pop();
    }
  }

  //清除消息
  clearnMessage(): void{
     this.messages = [];
  }



}
